package cn.bdqn.controller.wx;

import cn.bdqn.entity.DecryptInfo;
import cn.bdqn.entity.Entry;
import cn.bdqn.entity.SwiperImage;
import cn.bdqn.service.wx.IndexService;
import cn.bdqn.websocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ProjectName: ycbdqn
 * @Package: cn.bdqn.controller 首页
 * @Author: huat
 * @Date: 2020/2/29 22:33
 * @Version: 1.0
 */
@RestController
@RequestMapping("wx")
public class IndexController {
    @Autowired
    IndexService indexService;
    @Autowired
    WebSocketServer webSocketServer;
    /**
     * 获取轮播图
     * @return 轮播图集合
     */
    @RequestMapping("getSwiper")
    public List<SwiperImage> getSwiper(){
        return indexService.getSwiperImage();
    }
    /**
     * 解密并保存用户信息
     * decryptInfo 加密信息
     */
    @RequestMapping("addUser")
    public boolean addUser(DecryptInfo decryptInfo){

        return indexService.addUser(decryptInfo)>0?true:false;
    }
    /**
     * 获取就业学员信息
     */
    @RequestMapping("getEntry")
    public List<Entry> getEntry(){
        return indexService.getEntry();
    }
    /**
     * 解密并保存用户手机号
     * decryptInfo 加密信息
     */
    @RequestMapping("addPhone")
    public boolean addPhone(DecryptInfo decryptInfo){
        boolean flag=indexService.addPhone(decryptInfo)>0?true:false;
        if(flag){
            webSocketServer.sendMessage("1");
        }
        return flag;
    }

    /**
     * 根据id查询轮播图详情
     * @param id
     * @return
     */
    @RequestMapping("getSwiperById")
    public String getSwiperById(int id){
        return indexService.getSwiperById(id);
    }
}
